package com.client.common.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * result
 *
 * @author dzh
 * @date 2023/1/9 10:23
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ClientResult<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> ClientResult<T> make(int code, String msg, T data) {
        return new ClientResult<>(code, msg, data);
    }

    public static <T> ClientResult<T> make(int code, String msg) {
        return make(code, msg, null);
    }

    public static <T> ClientResult<T> makeSuccess(T data) {
        return make(0, "成功", data);
    }

    public static <T> ClientResult<T> makeFail(String msg) {
        return make(-1, msg);
    }
}
